package com.lbs.jiepiaisi.utils;

import android.app.Activity;
import android.content.Context;
import android.view.WindowManager;

/**
 * 手机屏幕管理类：获得手机屏幕的宽高
 * 编写人：尹德敏
 */
public class WindowSizeUtil {
	/**
	 * 屏幕的高度
	 */
	private static int height = 0;
	/**
	 * 屏幕的宽度
	 */
	private static int width = 0;
	/**
	 * 状态栏的高度
	 */
	private static int statusBarHeight = 0;

	public static void get(Context context) {
		if (height == 0 || width == 0) {
			Activity ac = (Activity) context;
			WindowManager wm = (WindowManager) ac
					.getSystemService(Context.WINDOW_SERVICE);
			width = wm.getDefaultDisplay().getWidth();
			height = wm.getDefaultDisplay().getHeight();
			int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
			if(resourceId>0){
				statusBarHeight = Utility.getPixelSize(context,resourceId);
			}
			height = height - statusBarHeight;
		}
	}

	public static int getHeight(Context context) {
		get(context);
		return height;
	}

	public static int getWidth(Context context) {
		get(context);
		return width;
	}

	public static int getStatusBarHeight(Context context) {
		get(context);
		return statusBarHeight;
	}
}
